"""
@author: tian-yan-tian-ge
@file: 2023.11.24 密码复杂度.py
@time: 2023/11/25 20:04
"""


def password_complexity_check(password):
    score = 0
    message = ""

    if len(password) > 8:
        score += 1
    if len(set(password)) > 3:
        score += 1
    if any(password.count(substr) > 1 for substr in password[:-2]):
        score += 1

    if score == 0:
        message = "密码过于简单，长度小于8，没有由3种以上字符组成。"
    elif score == 1:
        message = "密码符合基本要求，建议增加长度和复杂性以提升安全性。"
    else:
        message = "密码非常复杂，安全性很高，无需改进。"

    return score, message


password = "Abc12345"
score, message = password_complexity_check(password)
print("密码评分等级：", score)
print("需要改进的点：", message)
